package top.kaoshanji.p1ch05a.main;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import top.kaoshanji.p1ch05a.config.ProjectConfig;
import top.kaoshanji.p1ch05a.services.CommentService;

/**
 * 代码清单-p1ch05a-93页a：Main类用于测试单例bean的Spring行为
 * @author kaoshanji
 * ^_^
 * create time 2025/4/27 20:10
 */
public class Main {

    public static void main(String[] args) {

        var context = new AnnotationConfigApplicationContext(ProjectConfig.class);

        // 从上下文中获取两次CommentService bean
        var cs1 = context.getBean("commentService", CommentService.class);
        var cs2 = context.getBean("commentService", CommentService.class);

        // 这是一个对象
        System.out.println(cs1 == cs2);

    }

}
